﻿using AnlianCommon.Common.DTO;
using AnlianCommon.Enum;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace AnlianCommon.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class CommonProvincesController : ControllerBase
    {
        private readonly IMediator mediator;

        public CommonProvincesController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 上传图片
        /// </summary>
        /// <param name="file"></param>
        /// <returns></returns>
        [HttpPost]
        public Result UpLoadFile(IFormFile file)
        {
            var fileName = file.FileName;
            var path = Directory.GetCurrentDirectory() + @"\\wwwroot\\Images\\" + fileName;
            using (FileStream fs = new FileStream(path, FileMode.Create))
            {
                file.CopyTo(fs);
                fs.Flush();
            }
            var url = "/Images/" + fileName;
            return new Result() { Code = 0, Data = url };
        }
    }
}
